package xdu.lz.stage1_basic.chapter1_threadsafe.threadSafe;

public class SaleTicket1 extends Thread {
    public static int totalCount = 50;
    private String name;

    public SaleTicket1(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (totalCount>0){
            System.out.println(Thread.currentThread().getName()+"卖出了第"+(totalCount)+"张票");
            try {
                Thread.sleep(100L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            totalCount --;

        }
    }

    public static void main(String[] args) {
        new SaleTicket1("[1]").start();
        new SaleTicket1("[2]").start();
        new SaleTicket1("[3]").start();
    }
}
